import 'package:flutter/material.dart';

class Alert {
  static Future<void> alertFromBottomView(
    BuildContext context,
    Widget child, {
    double? elevation,
    bool isDismissible = true,
    bool enableDrag = true,
    Color? barrierColor,
  }) async {
    await showModalBottomSheet(
      backgroundColor: Colors.transparent,
      context: context,
      isScrollControlled: true,
      isDismissible: isDismissible,
      barrierColor: barrierColor,
      enableDrag: enableDrag,
      elevation: elevation,
      builder: (BuildContext context) {
        return child;
      },
    );
  }

  static Future<void> alertFromCenterView(BuildContext context, Widget child, {bool barrierDismissible = false}) async {
    await showDialog(
      context: context,
      barrierDismissible: barrierDismissible, //点击遮罩不关闭对话框, 默认可以关闭
      builder: (BuildContext context) {
        return AlertDialog(
          contentPadding: EdgeInsets.zero,
          buttonPadding: EdgeInsets.zero,
          insetPadding: EdgeInsets.zero,
          titlePadding: EdgeInsets.zero,
          backgroundColor: Colors.transparent,
          content: child,
        );
      },
    );
  }
}
